Object.size = function(obj) {
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }
    return size;
};


function showhideBar() {

  showhideconn();
  showhidehost();
  showhidemsg();
  if(document.hiddenhostinfo && document.hiddenconninfo && document.hiddenmsginfo) {
    document.getElementById("buttonhide").innerHTML = "<img width='30px' height='30px' src='images/show.png'/>";
  }
  else {
    document.getElementById("buttonhide").innerHTML = "<img width='30px' height='30px' src='images/hide.png'/>";
  }

};


function getResolved(ip) {

  if(!resolvedHosts[ip]) { return null; }
  else {
    return resolvedHosts[ip];
  }

}

function getResolvedLink(ip,service,cut) {

  if(!cut) { cut=25; }

  resolved=getResolved(ip);
  if(!resolved) resolved=ip;

  if(resolved.length>cut) { resolvedshort='..' + resolved.substring(resolved.length-cut,resolved.length); }
  else { resolvedshort=resolved; }

//Conta i dot e elimina qlli con meno di 1 punto. 
//   dots=0;
//   for(i=0;i<resolved.length;i++) {
//     if(resolved[i]=='.') dots++;
//   }
//   if(dots<1) { return ip; }

  if(service && service=='www') { return "<a href='http://" + resolved + "' target='_blank'>" + resolvedshort + "</a>"; }
  else if(service && service=='ftp') { return "<a href='ftp://" + resolved + "' target='_blank'>" + resolvedshort + "</a>"; }
  else if(service && service=='https') { return "<a href='https://" + resolved + "' target='_blank'>" + resolvedshort + "</a>"; }
  else { return resolvedshort; }
}